bytestring-0.11.3.0 is the first to have ShortByteString singleton.
Unsure about what version added concat, but mconcat = concat.
keyFile k =
let b = serializeKey'' k
in toOsPath $ if SB.any (`elem` needesc) b
- then SB.concat $ map esc (SB.unpack b)
+ then mconcat $ map esc (SB.unpack b)
else b
where
esc w = case chr (fromIntegral w) of
'%' -> "&s"
':' -> "&c"
'/' -> "%"
- _ -> SB.singleton w
+ _ -> SB.pack [w]
needesc = map (fromIntegral . ord) ['&', '%', ':', '/']